<template>
<uni-shadow-root class="host-ad-view-host-ad-view"><block>
    
    <ad v-if="hostAdType=='banner'" :unit-id="hostAdId" :ad-intervals="hostExtData.adDuration" @load="onAdLoad" @error="onAdError" @close="onAdClose">
    </ad>
    
    <ad-custom v-if="hostAdType=='template'" :unit-id="hostAdId" :ad-intervals="hostExtData.adDuration" @load="onAdLoad" @error="onAdError" @hide="onAdClose">
    </ad-custom>
    
    <ad v-if="hostAdType=='video'" :unit-id="hostAdId" ad-type="video" :ad-theme="hostExtData.videoAdTheme" @load="onAdLoad" @error="onAdError" @close="onAdClose">
    </ad>
</block></uni-shadow-root>
</template>

<script>

global['__wxVueOptions'] = {components:{}}

global['__wxRoute'] = 'host-ad-view/host-ad-view'
Component({

    properties: {
        //宿主广告类型
        hostAdType: {
            type: String
        },
        //宿主广告位id
        hostAdId: {
            type: String
        },
        //宿主扩展数据
        hostExtData: {
            type: Object
        }
    },

    methods: {
        //广告加载回调
        onAdLoad() {
            this.triggerEvent('adshow');
        },
        //广告错误回调
        onAdError(error) {
            this.triggerEvent('aderror', error);
        },
        //广告关闭回调
        onAdClose() {
            this.triggerEvent('adclose');
        }
    }
})
export default global['__wxComponents']['host-ad-view/host-ad-view']
</script>
<style platform="mp-weixin">

</style>